package com.lostsheep.dto;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**
 * <b><code>CommonDTO</code></b>
 * <p/>
 * Description
 * <p/>
 * <b>Creation Time:</b> 2024/7/6.
 *
 * @author dengzhen
 * @since spring-cloud-dubbo
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class CommonDTO<T> implements Serializable {
    
    private static final long serialVersionUID = 2244038482041740924L;
    
    private Integer code;
    private String message;
    private T data;

    public static <E> CommonDTO<E> success(Integer code, String message, E data) {
        return CommonDTO.<E>builder()
                .code(code)
                .message(message)
                .data(data)
                .build();
    }

    public static <E> CommonDTO<E> success(String message, E data) {
        return CommonDTO.<E>builder()
                .code(200)
                .message(message)
                .data(data)
                .build();
    }
}
